package org.digitalsoul.switchplugin.patterns;

import java.io.File;
import java.util.ArrayList;
import java.util.List;


public class PathBuilder {

    private List<String> paths;
    
    public PathBuilder() {
        this.paths = new ArrayList<String>();
    }
    
    public void build(File folder) {
        build(folder, null);
    }
    
    private void build(File folder, String path) {
        if (path == null) {
            paths.add("/");
            path = "";
        }
        else {
            if (path.length() > 0) {
                path += "/";
            }
            path += folder.getName();
            paths.add(path);
        }
        for (File file : folder.listFiles()) {
            if (file.isDirectory()) {
                build(file, path);
            }
        }
    }
    
    public List<String> getPaths() {
        return paths;
    }
}
